@extends('home/common/layout')
@section('content')
<!--主体内容-->
<link rel="stylesheet" href="{{asset('home')}}/plugins/normalize-css/normalize.css" />
<link rel="stylesheet" href="{{asset('home')}}/plugins/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="{{asset('home')}}/css/page-learing-pay.css" />
<script src="{{asset('home/js/jquery.min.js')}}"></script>
<div class="container">
    <div class="learing-pay">

        <table style="width:100%;">

            @if($course)
            @foreach($course as $val)
                <tr>
                    <td width="30%"><img src="{{$val['cover_img']}}" alt="" width="160" height="90"/></td>
                    <td width="30%">{{$val['course_desc']}}</td>
                    <td width="15%">{{$val['course_price']}}</td>
                    <td width="*"><a href="javascript:void(0);"  onclick="del(this,'{{url('home/shop/del',$val['course_id'])}}')" >删除</a></td>
                </tr>
                <tr>
                    <td><br/></td>
                </tr>
                @endforeach
                @else
                <tr>购物车空空如也。。。</tr>
                @endif
         </table>
    </div>

    <div class="learing-pay" style="margin:20px 0;">
        <div>已经选择了<span id="nmb">@if($course){{$number_price['number']}}@else 0 @endif</span>个商品</div>
        <div>总价格为：<span id="prc">@if($course){{$number_price['price']}}@else 0 @endif</span></div>
        @if($course)<div><a href="{{url('home/shop/cart_pay')}}" class="btn btn-primary" style="display:inline;">去结算</a></div> @endif
    </div>
</div>
<script>
    function del(obj,url){
        $.ajax({
            url:url,
            type:'get',
            dataType:'json',
            success:function(msg){
                if(msg.success==true){
                    $(obj).parents("tr").remove();
                    $('#nmb').text(msg.info.number);
                    $('#prc').text(msg.info.price);
                    if(msg.info.number==0){

                        $('.btn-primary').remove();
                    }
                    alert('刪除成功');

                }
            }
        });

    }

</script>

    <!-- 页面底部 -->

    <!--底部版权-->
   @endsection